package edu.spbsu.nonsm00th.qdiff.parser.word;

/**
 *
 * @author mbuzdov
 */
public enum Operation implements Word {

//    SUPER_EXPONENTIATION("??", 2, 4),
    EXPONENTIATION("^", 3, 2),
    MULTIPLICATION("*", 2, 2),
    DIVISION("/", 2, 2),
    ADDITION("+", 1),
    SUBTRACTION("-", 1);

    public static String ALPHABET;
    static {
        StringBuilder builder = new StringBuilder();
        for (Operation operation : values()) {
            builder.append(operation.value);
        }
        ALPHABET = builder.toString();
    }

    private String value;
    private int priority;

    private Operation(String value, int priority) {
        this.value = value;
        this.priority = priority;
    }

    @Deprecated
    private Operation(String value, int priority, int argumentsCount) {
        this.value = value;
        this.priority = priority;
    }

    public int getPriority() {
        return this.priority;
    }

    public static Operation getOperation(String value) {
        for (Operation operation : values()) {
            if (operation.value.equals(value)) {
                return operation;
            }
        }
        return null;
    }
}
